<template>
	<view class="questen">
		<van-cell-group>
		  <van-field
		    :value="content"
		    placeholder="请输入问题反馈"
			type="textarea"
		    border
			autosize
			:row="5"
			show-confirm-bar
		    @change="onChange"
		  />
		</van-cell-group>
		<view class="btn_box">
			<button type="primary" @click="subContent">提交反馈</button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				content: "",
			}
		},
		computed: {
			token() {
				return this.$store.state.token;
			}
		},
		methods: {
			onChange(e) {
				console.log(e.detail);
				this.content = e.detail
			},
			async subContent() {
				if(this.token) {
					if(this.content.length > 10) {
						let res = await this.$Request("POST", "/Index/feedback", { token: this.token, content: this.content })
						console.log(res);
						if(res.data.code == 202) {
							uni.showToast({
								title: "提交成功",
								icon: "success"
							})
							this.content = ""
							setTimeout(() => {
								uni.switchTab({
									url:"/pages/my/my"
								})
							}, 1000)
						}
					} else {
						uni.showToast({
							title: "请输入更多反馈",
							icon: "loading"
						}) 
						return false
					}
				} else {
					return false
				}
			}
		}
	}
</script>

<style scoped lang="scss">
	.questen {
		width: 100%;
		box-sizing: border-box;
		padding: 20rpx 30rpx;
		.btn_box {
			width: 100%;
			box-sizing: border-box;
			padding: 20rpx 0;
		}
	}
</style>
